#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<map>

using namespace std;

typedef struct BTNode
{
	char data;
	struct BTNode *lchild,*rchild;
}tBTNode;

map<char,int> map_val_pos;

void post_order_traverse(char *pre,char *in,int len)
{
	if(len<=0)
	{
		return ;
	}

	char ch = pre[0];

	int i;
	for(i=0;in[i]!=ch;i++);

	post_order_traverse(pre+1,in,i);

	post_order_traverse(pre+i+1,in+i+1,len-i-1);

	cout<<pre[0];
}

int main()
{
	char pre_order[30];
	char in_order[30];

	while(cin>>pre_order>>in_order)
	{
		map_val_pos.clear();
		post_order_traverse( pre_order,in_order,strlen(pre_order) );
		cout<<endl;
	}

	return 0;
}
